use crate::{config::Config, http, resource::Resource};
use route_recognizer::Params;

///???
pub(crate) fn rest(route_params: &[Params]) -> Option<&str> {
    route_params
        .last()
        .and_then(|params| params.find("--tide-path-rest"))
}

pin_project_lite::pin_project! {
    ///rapid 中的requset实例
    #[derive(Debug)]
    pub struct Request {
        #[pin]
        pub(crate) req: http::Request,
        pub(crate) route_params: Vec<Params>,
        pub(crate) resource: Resource,
        pub(crate) config: Config,
    }
}

impl Request {
    pub fn new(
        req: http::Request,
        route_params: Vec<Params>,
        resource: Resource,
        config: Config,
    ) -> Self {
        Request {
            req,
            resource,
            route_params,
            config,
        }
    }
}
